import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore('user', () => {
  const userInfo = ref<any>(null)
  const token = ref<string>('')

  const setUserInfo = (info: any) => {
    userInfo.value = info
  }

  const setToken = (t: string) => {
    token.value = t
  }

  const clearUser = () => {
    userInfo.value = null
    token.value = ''
  }

  return {
    userInfo,
    token,
    setUserInfo,
    setToken,
    clearUser
  }
})